package qr.server.admin;

import javax.swing.DefaultListModel;
import javax.swing.JPanel;

import qr.core.Game;
import qr.core.Location;

/**
 * Base class for all app screens.
 * 
 * Each screen is a state in the state pattern. States may transition to other
 * states by {@link ApplicationScreen#switchTo(String)}. States do not need to
 * concern themselves with the parent ({@link ApplicationWindow}), only this
 * base class.
 * 
 * Transitions are implemented as a lookup table. A state may transition to
 * any other state as long as the parent can look up the state in its
 * transition table.
 * 
 * @author Brian
 *
 */
@SuppressWarnings("serial")
public abstract class ApplicationScreen extends JPanel {
	
	private ApplicationWindow parent;
	
	/**
	 * Base constructor.
	 * 
	 * @param parent
	 */
	public ApplicationScreen(ApplicationWindow parent) {
		this.parent = parent;
	}
	
	/**
	 * Constructor with received object
	 * 
	 * @param parent
	 * @param obj
	 */
	public ApplicationScreen(ApplicationWindow parent, Object[] objs) {
		this.parent = parent;
	}

	/**
	 * Switch parent's rendered frame.
	 * 
	 * @param screen Name of screen to switch to
	 */
	public void switchTo(String screen) {
		this.parent.render(screen);
	}
	
	/**
	 * Switch parent's rendered frame, passing given object
	 * 
	 * @param screen Name of screen to switch to
	 * @Param obj Object to pass to the new screen
	 */
	public void switchTo(String screen, Object[] objs) {
		this.parent.render(screen, objs);
	}
}
